﻿
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');


FantastPlatform.UI.PatrolTaskPointForm = function (config) {
    Ext.apply(this, config);
    var policeComboBox = new FantastPlatform.CaseManagement.SearchField({
        fieldLabel: '带队负责人',
        name: 'LeaderName',
        hiddenName: 'LeaderId',
        valueField: 'LeaderName',
        allowBlank: false,
        url: "../Service/PersonTaskService.aspx?Action=GetPersonByOrgCode",
        readOnly: true,
        width: 130
    });
    this.items = [{
        xtype: 'fieldset',
        title: '下达调警单位填写',
        collapsible: true,
        height: 270,
        layout: 'column',
        labelSeparator: '：',
        items: [{
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '任务名称',
                name: 'TaskName',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '分管局领导',
                name: 'DefaultLeader',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '任务类型',
                name: 'TaskType',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .4,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '牵头责任部门',
                name: 'DutyOrganization',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '部门责任人',
                name: 'DutyLeader',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [new FantastPlatform.UI.DateTimeField({
                fieldLabel: '开始时间',
                name: 'BeginTime',
                timeFormat: 'H:i',
                dateFormat: 'Y-m-d',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [new FantastPlatform.UI.DateTimeField({
                fieldLabel: '结束时间',
                name: 'EndTime',
                timeFormat: 'H:i',
                dateFormat: 'Y-m-d',
                readOnly: true,
                anchor: '95%'
            })]
        }, { columnWidth: .4,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '执行部门',
                name: 'ExecOrganization',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '车辆数',
                name: 'SelfOrgCar',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextArea({
                fieldLabel: '巡逻区域',
                name: 'PositionName',
                readOnly: true,
                height: 50,
                anchor: '95%'
            })]
        }, {
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextArea({
                fieldLabel: '工作要求',
                name: 'Require',
                readOnly: true,
                height: 50,
                anchor: '95%'
            })]
        }]
    }, {
        xtype: 'fieldset',
        title: '执行单位填写',
        collapsible: true,
        height: 200,
        layout: 'column',
        labelSeparator: '：',
        items: [{
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [policeComboBox]
        }, {
            columnWidth: .5,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '负责人电话',
                name: 'TelPhone',
                allowBlank: false,
                anchor: '95%'
            })]
        }, {
            columnWidth: .8,
            layout: 'form',
            border: false,
            items: [new Ext.form.TextField({
                fieldLabel: '巡逻区域标注',
                name: 'Points',
                id: 'GpsPoints',
                readOnly: true,
                allowBlank: false,
                width: 200
            })]
        }, {
            columnWidth: .2,
            layout: 'form',
            border: false,
            items: [new Ext.Button({
                text: '地图标记',
                id: 'MapBtn',
                handler: function () {
                    openWind("../MapAddress.aspx?longitude=" + Ext.getCmp('AddressX').getValue() + "&latitude=" + Ext.getCmp('AddressY').getValue(), id, '标记执勤地点', 830, 560, 'new_tab');
                }
            })]
        }, {
            columnWidth: .4,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '执行部门人数',
                name: 'SelfOrgPersonNum',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .4,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextArea({
                fieldLabel: '执行部门人员',
                name: 'SelfOrgPersons',
                allowBlank: false,
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .2,
            layout: 'form',
            border: false,
            items: [new Ext.Button({
                text: '添加执行人员',
                id: 'MapBtn',
                handler: function () {
                    openWind("../PersonTaskForm.aspx?Id=" + this.Id, id, '标记执勤地点', 830, 560, 'new_tab');
                }
            })]
        }, {
            columnWidth: .3,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '支援部门',
                name: 'OtherOrgName',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .3,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '支援部门人数',
                name: 'OtherOrgPersonNum',
                readOnly: true,
                anchor: '95%'
            })]
        }, {
            columnWidth: .4,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextArea({
                fieldLabel: '支援部门人员',
                name: 'OtherOrgPersons',
                allowBlank: false,
                height: 50,
                anchor: '95%'
            })]
        }]
    }];
    FantastPlatform.UI.PatrolTaskPointForm.superclass.constructor.call(this, {
        bodyStyle: 'padding:5px',
        collapsible: true,
        labelAlign: 'right',
        autoScroll: true,
        border: false
    });
};

Ext.extend(FantastPlatform.UI.PatrolTaskPointForm, Ext.form.FormPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.PatrolTaskPointForm.superclass.onRender.call(this, ct, position);
        if (this.Id && this.Id != 0) {
            this.add(new Ext.form.Hidden({ name: 'Id', value: this.Id }));
            var Form = this.form;
            this.form.load({
                url: '../Service/PatrolTaskPointService.aspx?Action=Get',
                params: { id: this.Id },
                waitMsg: '正在读取数据...',
                waitTitle: '请稍后...',
                failure: function (form, action) {
                    if (action.failureType != 'client') {
                        showErrorMessage('操作失败', action.result.message, '');
                    }
                },
                success: function (form, action) {

                }
            });
        }
    }
});

